using NUnit.Framework;

namespace ValidationFramework.Tests
{
    [TestFixture]
    public class RangeDecimalRuleAttributeTest
    {

       const double expectedMinimum = 2;
        const double expectedMaximum = 4;
        const decimal expectedMinimumDecimal = 2;
        const decimal expectedMaximumDecimal = 4;



        [Test]
        public void CheckValues()
        {
            var ruleAttribute = new RangeDecimalRuleAttribute(expectedMinimum, expectedMaximum);
            Assert.AreEqual(expectedMinimumDecimal, ruleAttribute.Minimum);
            Assert.AreEqual(expectedMaximumDecimal, ruleAttribute.Maximum);

            var propertyRule = (RangeRule<decimal>)ruleAttribute.CreateRule(new MockPropertyDescriptor<decimal>("foo"));
            var parameterRule = (RangeRule<decimal>)ruleAttribute.CreateRule(new MockParameterDescriptor<decimal>("foo"));

            Assert.AreEqual(expectedMinimumDecimal, propertyRule.Minimum);
            Assert.AreEqual(expectedMaximumDecimal, propertyRule.Maximum);

            Assert.AreEqual(expectedMinimumDecimal, parameterRule.Minimum);
            Assert.AreEqual(expectedMaximumDecimal, parameterRule.Maximum);

        }


        [Test]
        public void CallAttributeTester()
        {
            AttributeTester.CheckDefaultValues<decimal>(new RangeDecimalRuleAttribute(expectedMinimum, expectedMaximum), true, true);
            AttributeTester.CheckNonDefaultValues<decimal>(new RangeDecimalRuleAttribute(expectedMinimum, expectedMaximum), true, true);
        }

    }
}